import {
  useI18n
} from "@/locales/setupI18n";

export const state = {
  /** 应用LOGO */
  logoSrc: '',
  /** 应用标题 */
  appTitle: '',
  /** 应用描述 */
  appDescription: '',
  /** 应用子描述 */
  appSubdescription: '',
}

/** 获取器 */
export const getters = {
  /** 获取LOGO */
  getLogo: (state, getters, dispatch) => {
    return state.logoSrc || '/static/images/logos/logo.png';
  },
  /** 获取应用标题 */
  getAppTitle: state => {
    const {
      t
    } = useI18n();
    return state.appTitle || t('pages.sys.about.corporationText');
  },
  /** 获取应用描述 */
  getAppDescription: state => {
    const {
      t
    } = useI18n();
    return state.appDescription || t('pages.sys.about.sloganText');
  },
  /** 获取应用子描述 */
  getAppSubdescription: state => {
    const {
      t
    } = useI18n();
    return state.appSubdescription|| t('pages.sys.about.sloganText');
  },
}

/** 方法 */
export const actions = {
	/** 设置LOGO */
	setLogo: function({
		state,
		commit,
		dispatch
	}, logo) {
    state.logoSrc = logo;
	},
	/** 设置应用标题 */
	setAppTitle: function({
		state,
		commit,
		dispatch
	}, title) {
		state.appTitle = title;
	},
	/** 设置应用描述 */
	setAppDescription: function({
		state,
		commit,
		dispatch
	}, description) {
		state.appDescription = description;
	},
  /** 设置应用子描述 */
  setAppSubdescription: function({
  	state,
  	commit,
  	dispatch
  }, subdescription) {
  	state.appSubdescription = subdescription;
  },
}
